const {defineConfig} = require('@vue/cli-service');

module.exports = defineConfig({

  configureWebpack: {
    module: {
      rules: [
        // 新增的规则
        {
          test: /node_modules\/ini\/lib\/ini\.js$/,
          use: [
            {
              loader: 'babel-loader',
              options: {
                presets: ['@babel/preset-env'],
                plugins: ['@babel/plugin-proposal-optional-chaining'],
              },
            },
          ],
        },
        // 原有的规则
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: [
            {
              loader: 'babel-loader',
              options: {
                cacheDirectory: true,
                presets: ['@babel/preset-env'],
              },
            },
          ],
        },
      ],
    },
  },
  transpileDependencies: true,

  pluginOptions: {
    // 应用程序插件
    electronBuilder: {
      nodeIntegration: true,

      builderOptions: {
        publish: [],
        productName: "石油化工",

        nsis: {
          oneClick: false,
          perMachine: true,
          allowToChangeInstallationDirectory: true,
          createDesktopShortcut: true, // 明确设置创建桌面快捷方式的选项
          shortcutName: '石油化工',
          createStartMenuShortcut: true, // 明确设置创建开始菜单快
          installerIcon: './public/install.ico',
          uninstallerIcon: './public/unInstall.ico',

        },
        win: {
          artifactName: '石油化工安装程序.exe',
          icon: './public/石油化工.ico',
          legalTrademarks: '🐕淇',
        },
        asar: true,
        asarUnpack: [
          "data/*"
        ],
        extraResources: [
          {
            from: './config.ini',
            to: '../',
          }
        ],
      }
    }
  },

});
